/**
 * 首页
 */
layui.use(["form","layer"],function () {

	var form=layui.form;
	var layer = layui.layer;

	var unlock=0;

	$(document).on("click","#login_button",function(){
		var id=$('#id').val();
		var password=$('#password').val();
		var identity=$('input:radio[name="identity"]:checked').val();
		if(id==""||password==""||identity==null){
			layer.msg("登录信息不能为空");
		}
		if(unlock==0){
			layer.msg("未验证！！！")
		}
		else{
			$.ajax({
				url:"login",
				post:"post",
				async:true,
				data:{
					"id":id,
					"password":password,
					"identity":identity,
				},
				dataType:"json",
				success:function(data){
					if(data.mark==1){
						$.session.set("id",data.id);
						$.session.set("name",data.name);
						$.session.set("identity",identity);
						$.session.set("college",data.college);
						window.location.href=identity;
					}
					if(data.mark==0){
						layer.msg("登录信息有误!");
					}
				},
				error:function(){
					layer.msg("系统繁忙,请稍后再试");
				}
			});
		}
	});

	//验证码相关
	$('#foo').slideToUnlock({
		height:35,
		width:350,
		text : '滑动验证',
		succText : 'OK',
		handleColor:'#0099CC',

		successFunc:function () {
			unlock=1;
		}
	});

});